/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
"use strict";

var $protobuf = require("protobufjs/minimal");

// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;

// Exported root namespace
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});

$root.xtp = (function() {

    /**
     * Namespace xtp.
     * @exports xtp
     * @namespace
     */
    var xtp = {};

    xtp.Frame = (function() {

        /**
         * Properties of a Frame.
         * @memberof xtp
         * @interface IFrame
         * @property {number|null} [handlerId] Frame handlerId
         * @property {xtp.IMessage|null} [message] Frame message
         * @property {xtp.IClose|null} [close] Frame close
         * @property {xtp.IMessage|null} ["yield"] Frame yield
         * @property {xtp.IEnd|null} [end] Frame end
         */

        /**
         * Constructs a new Frame.
         * @memberof xtp
         * @classdesc Represents a Frame.
         * @implements IFrame
         * @constructor
         * @param {xtp.IFrame=} [properties] Properties to set
         */
        function Frame(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * Frame handlerId.
         * @member {number} handlerId
         * @memberof xtp.Frame
         * @instance
         */
        Frame.prototype.handlerId = 0;

        /**
         * Frame message.
         * @member {xtp.IMessage|null|undefined} message
         * @memberof xtp.Frame
         * @instance
         */
        Frame.prototype.message = null;

        /**
         * Frame close.
         * @member {xtp.IClose|null|undefined} close
         * @memberof xtp.Frame
         * @instance
         */
        Frame.prototype.close = null;

        /**
         * Frame yield.
         * @member {xtp.IMessage|null|undefined} yield
         * @memberof xtp.Frame
         * @instance
         */
        Frame.prototype["yield"] = null;

        /**
         * Frame end.
         * @member {xtp.IEnd|null|undefined} end
         * @memberof xtp.Frame
         * @instance
         */
        Frame.prototype.end = null;

        // OneOf field names bound to virtual getters and setters
        var $oneOfFields;

        /**
         * Frame type.
         * @member {"message"|"close"|"yield"|"end"|undefined} type
         * @memberof xtp.Frame
         * @instance
         */
        Object.defineProperty(Frame.prototype, "type", {
            get: $util.oneOfGetter($oneOfFields = ["message", "close", "yield", "end"]),
            set: $util.oneOfSetter($oneOfFields)
        });

        /**
         * Creates a new Frame instance using the specified properties.
         * @function create
         * @memberof xtp.Frame
         * @static
         * @param {xtp.IFrame=} [properties] Properties to set
         * @returns {xtp.Frame} Frame instance
         */
        Frame.create = function create(properties) {
            return new Frame(properties);
        };

        /**
         * Encodes the specified Frame message. Does not implicitly {@link xtp.Frame.verify|verify} messages.
         * @function encode
         * @memberof xtp.Frame
         * @static
         * @param {xtp.IFrame} message Frame message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Frame.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            if (message.handlerId != null && Object.hasOwnProperty.call(message, "handlerId"))
                writer.uint32(/* id 1, wireType 0 =*/8).int32(message.handlerId);
            if (message.message != null && Object.hasOwnProperty.call(message, "message"))
                $root.xtp.Message.encode(message.message, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
            if (message.close != null && Object.hasOwnProperty.call(message, "close"))
                $root.xtp.Close.encode(message.close, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
            if (message["yield"] != null && Object.hasOwnProperty.call(message, "yield"))
                $root.xtp.Message.encode(message["yield"], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
            if (message.end != null && Object.hasOwnProperty.call(message, "end"))
                $root.xtp.End.encode(message.end, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim();
            return writer;
        };

        /**
         * Encodes the specified Frame message, length delimited. Does not implicitly {@link xtp.Frame.verify|verify} messages.
         * @function encodeDelimited
         * @memberof xtp.Frame
         * @static
         * @param {xtp.IFrame} message Frame message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Frame.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes a Frame message from the specified reader or buffer.
         * @function decode
         * @memberof xtp.Frame
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {xtp.Frame} Frame
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Frame.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.xtp.Frame();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1:
                    message.handlerId = reader.int32();
                    break;
                case 2:
                    message.message = $root.xtp.Message.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.close = $root.xtp.Close.decode(reader, reader.uint32());
                    break;
                case 4:
                    message["yield"] = $root.xtp.Message.decode(reader, reader.uint32());
                    break;
                case 5:
                    message.end = $root.xtp.End.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            return message;
        };

        /**
         * Decodes a Frame message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof xtp.Frame
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {xtp.Frame} Frame
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Frame.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies a Frame message.
         * @function verify
         * @memberof xtp.Frame
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        Frame.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            var properties = {};
            if (message.handlerId != null && message.hasOwnProperty("handlerId"))
                if (!$util.isInteger(message.handlerId))
                    return "handlerId: integer expected";
            if (message.message != null && message.hasOwnProperty("message")) {
                properties.type = 1;
                {
                    var error = $root.xtp.Message.verify(message.message);
                    if (error)
                        return "message." + error;
                }
            }
            if (message.close != null && message.hasOwnProperty("close")) {
                if (properties.type === 1)
                    return "type: multiple values";
                properties.type = 1;
                {
                    var error = $root.xtp.Close.verify(message.close);
                    if (error)
                        return "close." + error;
                }
            }
            if (message["yield"] != null && message.hasOwnProperty("yield")) {
                if (properties.type === 1)
                    return "type: multiple values";
                properties.type = 1;
                {
                    var error = $root.xtp.Message.verify(message["yield"]);
                    if (error)
                        return "yield." + error;
                }
            }
            if (message.end != null && message.hasOwnProperty("end")) {
                if (properties.type === 1)
                    return "type: multiple values";
                properties.type = 1;
                {
                    var error = $root.xtp.End.verify(message.end);
                    if (error)
                        return "end." + error;
                }
            }
            return null;
        };

        /**
         * Creates a Frame message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof xtp.Frame
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {xtp.Frame} Frame
         */
        Frame.fromObject = function fromObject(object) {
            if (object instanceof $root.xtp.Frame)
                return object;
            var message = new $root.xtp.Frame();
            if (object.handlerId != null)
                message.handlerId = object.handlerId | 0;
            if (object.message != null) {
                if (typeof object.message !== "object")
                    throw TypeError(".xtp.Frame.message: object expected");
                message.message = $root.xtp.Message.fromObject(object.message);
            }
            if (object.close != null) {
                if (typeof object.close !== "object")
                    throw TypeError(".xtp.Frame.close: object expected");
                message.close = $root.xtp.Close.fromObject(object.close);
            }
            if (object["yield"] != null) {
                if (typeof object["yield"] !== "object")
                    throw TypeError(".xtp.Frame.yield: object expected");
                message["yield"] = $root.xtp.Message.fromObject(object["yield"]);
            }
            if (object.end != null) {
                if (typeof object.end !== "object")
                    throw TypeError(".xtp.Frame.end: object expected");
                message.end = $root.xtp.End.fromObject(object.end);
            }
            return message;
        };

        /**
         * Creates a plain object from a Frame message. Also converts values to other types if specified.
         * @function toObject
         * @memberof xtp.Frame
         * @static
         * @param {xtp.Frame} message Frame
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        Frame.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults)
                object.handlerId = 0;
            if (message.handlerId != null && message.hasOwnProperty("handlerId"))
                object.handlerId = message.handlerId;
            if (message.message != null && message.hasOwnProperty("message")) {
                object.message = $root.xtp.Message.toObject(message.message, options);
                if (options.oneofs)
                    object.type = "message";
            }
            if (message.close != null && message.hasOwnProperty("close")) {
                object.close = $root.xtp.Close.toObject(message.close, options);
                if (options.oneofs)
                    object.type = "close";
            }
            if (message["yield"] != null && message.hasOwnProperty("yield")) {
                object["yield"] = $root.xtp.Message.toObject(message["yield"], options);
                if (options.oneofs)
                    object.type = "yield";
            }
            if (message.end != null && message.hasOwnProperty("end")) {
                object.end = $root.xtp.End.toObject(message.end, options);
                if (options.oneofs)
                    object.type = "end";
            }
            return object;
        };

        /**
         * Converts this Frame to JSON.
         * @function toJSON
         * @memberof xtp.Frame
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        Frame.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return Frame;
    })();

    xtp.Message = (function() {

        /**
         * Properties of a Message.
         * @memberof xtp
         * @interface IMessage
         * @property {Uint8Array|null} [data] Message data
         * @property {xtp.IHandlerInfo|null} [handlerInfo] Message handlerInfo
         */

        /**
         * Constructs a new Message.
         * @memberof xtp
         * @classdesc Represents a Message.
         * @implements IMessage
         * @constructor
         * @param {xtp.IMessage=} [properties] Properties to set
         */
        function Message(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * Message data.
         * @member {Uint8Array} data
         * @memberof xtp.Message
         * @instance
         */
        Message.prototype.data = $util.newBuffer([]);

        /**
         * Message handlerInfo.
         * @member {xtp.IHandlerInfo|null|undefined} handlerInfo
         * @memberof xtp.Message
         * @instance
         */
        Message.prototype.handlerInfo = null;

        // OneOf field names bound to virtual getters and setters
        var $oneOfFields;

        /**
         * Message type.
         * @member {"data"|"handlerInfo"|undefined} type
         * @memberof xtp.Message
         * @instance
         */
        Object.defineProperty(Message.prototype, "type", {
            get: $util.oneOfGetter($oneOfFields = ["data", "handlerInfo"]),
            set: $util.oneOfSetter($oneOfFields)
        });

        /**
         * Creates a new Message instance using the specified properties.
         * @function create
         * @memberof xtp.Message
         * @static
         * @param {xtp.IMessage=} [properties] Properties to set
         * @returns {xtp.Message} Message instance
         */
        Message.create = function create(properties) {
            return new Message(properties);
        };

        /**
         * Encodes the specified Message message. Does not implicitly {@link xtp.Message.verify|verify} messages.
         * @function encode
         * @memberof xtp.Message
         * @static
         * @param {xtp.IMessage} message Message message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Message.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            if (message.data != null && Object.hasOwnProperty.call(message, "data"))
                writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.data);
            if (message.handlerInfo != null && Object.hasOwnProperty.call(message, "handlerInfo"))
                $root.xtp.HandlerInfo.encode(message.handlerInfo, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
            return writer;
        };

        /**
         * Encodes the specified Message message, length delimited. Does not implicitly {@link xtp.Message.verify|verify} messages.
         * @function encodeDelimited
         * @memberof xtp.Message
         * @static
         * @param {xtp.IMessage} message Message message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Message.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes a Message message from the specified reader or buffer.
         * @function decode
         * @memberof xtp.Message
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {xtp.Message} Message
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Message.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.xtp.Message();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1:
                    message.data = reader.bytes();
                    break;
                case 2:
                    message.handlerInfo = $root.xtp.HandlerInfo.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            return message;
        };

        /**
         * Decodes a Message message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof xtp.Message
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {xtp.Message} Message
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Message.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies a Message message.
         * @function verify
         * @memberof xtp.Message
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        Message.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            var properties = {};
            if (message.data != null && message.hasOwnProperty("data")) {
                properties.type = 1;
                if (!(message.data && typeof message.data.length === "number" || $util.isString(message.data)))
                    return "data: buffer expected";
            }
            if (message.handlerInfo != null && message.hasOwnProperty("handlerInfo")) {
                if (properties.type === 1)
                    return "type: multiple values";
                properties.type = 1;
                {
                    var error = $root.xtp.HandlerInfo.verify(message.handlerInfo);
                    if (error)
                        return "handlerInfo." + error;
                }
            }
            return null;
        };

        /**
         * Creates a Message message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof xtp.Message
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {xtp.Message} Message
         */
        Message.fromObject = function fromObject(object) {
            if (object instanceof $root.xtp.Message)
                return object;
            var message = new $root.xtp.Message();
            if (object.data != null)
                if (typeof object.data === "string")
                    $util.base64.decode(object.data, message.data = $util.newBuffer($util.base64.length(object.data)), 0);
                else if (object.data.length)
                    message.data = object.data;
            if (object.handlerInfo != null) {
                if (typeof object.handlerInfo !== "object")
                    throw TypeError(".xtp.Message.handlerInfo: object expected");
                message.handlerInfo = $root.xtp.HandlerInfo.fromObject(object.handlerInfo);
            }
            return message;
        };

        /**
         * Creates a plain object from a Message message. Also converts values to other types if specified.
         * @function toObject
         * @memberof xtp.Message
         * @static
         * @param {xtp.Message} message Message
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        Message.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (message.data != null && message.hasOwnProperty("data")) {
                object.data = options.bytes === String ? $util.base64.encode(message.data, 0, message.data.length) : options.bytes === Array ? Array.prototype.slice.call(message.data) : message.data;
                if (options.oneofs)
                    object.type = "data";
            }
            if (message.handlerInfo != null && message.hasOwnProperty("handlerInfo")) {
                object.handlerInfo = $root.xtp.HandlerInfo.toObject(message.handlerInfo, options);
                if (options.oneofs)
                    object.type = "handlerInfo";
            }
            return object;
        };

        /**
         * Converts this Message to JSON.
         * @function toJSON
         * @memberof xtp.Message
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        Message.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return Message;
    })();

    xtp.HandlerInfo = (function() {

        /**
         * Properties of a HandlerInfo.
         * @memberof xtp
         * @interface IHandlerInfo
         * @property {number|null} [handlerId] HandlerInfo handlerId
         * @property {number|null} [channelSize] HandlerInfo channelSize
         * @property {Uint8Array|null} [data] HandlerInfo data
         */

        /**
         * Constructs a new HandlerInfo.
         * @memberof xtp
         * @classdesc Represents a HandlerInfo.
         * @implements IHandlerInfo
         * @constructor
         * @param {xtp.IHandlerInfo=} [properties] Properties to set
         */
        function HandlerInfo(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * HandlerInfo handlerId.
         * @member {number} handlerId
         * @memberof xtp.HandlerInfo
         * @instance
         */
        HandlerInfo.prototype.handlerId = 0;

        /**
         * HandlerInfo channelSize.
         * @member {number} channelSize
         * @memberof xtp.HandlerInfo
         * @instance
         */
        HandlerInfo.prototype.channelSize = 0;

        /**
         * HandlerInfo data.
         * @member {Uint8Array} data
         * @memberof xtp.HandlerInfo
         * @instance
         */
        HandlerInfo.prototype.data = $util.newBuffer([]);

        /**
         * Creates a new HandlerInfo instance using the specified properties.
         * @function create
         * @memberof xtp.HandlerInfo
         * @static
         * @param {xtp.IHandlerInfo=} [properties] Properties to set
         * @returns {xtp.HandlerInfo} HandlerInfo instance
         */
        HandlerInfo.create = function create(properties) {
            return new HandlerInfo(properties);
        };

        /**
         * Encodes the specified HandlerInfo message. Does not implicitly {@link xtp.HandlerInfo.verify|verify} messages.
         * @function encode
         * @memberof xtp.HandlerInfo
         * @static
         * @param {xtp.IHandlerInfo} message HandlerInfo message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        HandlerInfo.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            if (message.handlerId != null && Object.hasOwnProperty.call(message, "handlerId"))
                writer.uint32(/* id 1, wireType 0 =*/8).int32(message.handlerId);
            if (message.channelSize != null && Object.hasOwnProperty.call(message, "channelSize"))
                writer.uint32(/* id 2, wireType 0 =*/16).int32(message.channelSize);
            if (message.data != null && Object.hasOwnProperty.call(message, "data"))
                writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.data);
            return writer;
        };

        /**
         * Encodes the specified HandlerInfo message, length delimited. Does not implicitly {@link xtp.HandlerInfo.verify|verify} messages.
         * @function encodeDelimited
         * @memberof xtp.HandlerInfo
         * @static
         * @param {xtp.IHandlerInfo} message HandlerInfo message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        HandlerInfo.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes a HandlerInfo message from the specified reader or buffer.
         * @function decode
         * @memberof xtp.HandlerInfo
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {xtp.HandlerInfo} HandlerInfo
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        HandlerInfo.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.xtp.HandlerInfo();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1:
                    message.handlerId = reader.int32();
                    break;
                case 2:
                    message.channelSize = reader.int32();
                    break;
                case 3:
                    message.data = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            return message;
        };

        /**
         * Decodes a HandlerInfo message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof xtp.HandlerInfo
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {xtp.HandlerInfo} HandlerInfo
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        HandlerInfo.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies a HandlerInfo message.
         * @function verify
         * @memberof xtp.HandlerInfo
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        HandlerInfo.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            if (message.handlerId != null && message.hasOwnProperty("handlerId"))
                if (!$util.isInteger(message.handlerId))
                    return "handlerId: integer expected";
            if (message.channelSize != null && message.hasOwnProperty("channelSize"))
                if (!$util.isInteger(message.channelSize))
                    return "channelSize: integer expected";
            if (message.data != null && message.hasOwnProperty("data"))
                if (!(message.data && typeof message.data.length === "number" || $util.isString(message.data)))
                    return "data: buffer expected";
            return null;
        };

        /**
         * Creates a HandlerInfo message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof xtp.HandlerInfo
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {xtp.HandlerInfo} HandlerInfo
         */
        HandlerInfo.fromObject = function fromObject(object) {
            if (object instanceof $root.xtp.HandlerInfo)
                return object;
            var message = new $root.xtp.HandlerInfo();
            if (object.handlerId != null)
                message.handlerId = object.handlerId | 0;
            if (object.channelSize != null)
                message.channelSize = object.channelSize | 0;
            if (object.data != null)
                if (typeof object.data === "string")
                    $util.base64.decode(object.data, message.data = $util.newBuffer($util.base64.length(object.data)), 0);
                else if (object.data.length)
                    message.data = object.data;
            return message;
        };

        /**
         * Creates a plain object from a HandlerInfo message. Also converts values to other types if specified.
         * @function toObject
         * @memberof xtp.HandlerInfo
         * @static
         * @param {xtp.HandlerInfo} message HandlerInfo
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        HandlerInfo.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults) {
                object.handlerId = 0;
                object.channelSize = 0;
                if (options.bytes === String)
                    object.data = "";
                else {
                    object.data = [];
                    if (options.bytes !== Array)
                        object.data = $util.newBuffer(object.data);
                }
            }
            if (message.handlerId != null && message.hasOwnProperty("handlerId"))
                object.handlerId = message.handlerId;
            if (message.channelSize != null && message.hasOwnProperty("channelSize"))
                object.channelSize = message.channelSize;
            if (message.data != null && message.hasOwnProperty("data"))
                object.data = options.bytes === String ? $util.base64.encode(message.data, 0, message.data.length) : options.bytes === Array ? Array.prototype.slice.call(message.data) : message.data;
            return object;
        };

        /**
         * Converts this HandlerInfo to JSON.
         * @function toJSON
         * @memberof xtp.HandlerInfo
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        HandlerInfo.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return HandlerInfo;
    })();

    xtp.Close = (function() {

        /**
         * Properties of a Close.
         * @memberof xtp
         * @interface IClose
         * @property {xtp.IError|null} [error] Close error
         */

        /**
         * Constructs a new Close.
         * @memberof xtp
         * @classdesc Represents a Close.
         * @implements IClose
         * @constructor
         * @param {xtp.IClose=} [properties] Properties to set
         */
        function Close(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * Close error.
         * @member {xtp.IError|null|undefined} error
         * @memberof xtp.Close
         * @instance
         */
        Close.prototype.error = null;

        /**
         * Creates a new Close instance using the specified properties.
         * @function create
         * @memberof xtp.Close
         * @static
         * @param {xtp.IClose=} [properties] Properties to set
         * @returns {xtp.Close} Close instance
         */
        Close.create = function create(properties) {
            return new Close(properties);
        };

        /**
         * Encodes the specified Close message. Does not implicitly {@link xtp.Close.verify|verify} messages.
         * @function encode
         * @memberof xtp.Close
         * @static
         * @param {xtp.IClose} message Close message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Close.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            if (message.error != null && Object.hasOwnProperty.call(message, "error"))
                $root.xtp.Error.encode(message.error, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
            return writer;
        };

        /**
         * Encodes the specified Close message, length delimited. Does not implicitly {@link xtp.Close.verify|verify} messages.
         * @function encodeDelimited
         * @memberof xtp.Close
         * @static
         * @param {xtp.IClose} message Close message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Close.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes a Close message from the specified reader or buffer.
         * @function decode
         * @memberof xtp.Close
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {xtp.Close} Close
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Close.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.xtp.Close();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1:
                    message.error = $root.xtp.Error.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            return message;
        };

        /**
         * Decodes a Close message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof xtp.Close
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {xtp.Close} Close
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Close.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies a Close message.
         * @function verify
         * @memberof xtp.Close
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        Close.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            if (message.error != null && message.hasOwnProperty("error")) {
                var error = $root.xtp.Error.verify(message.error);
                if (error)
                    return "error." + error;
            }
            return null;
        };

        /**
         * Creates a Close message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof xtp.Close
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {xtp.Close} Close
         */
        Close.fromObject = function fromObject(object) {
            if (object instanceof $root.xtp.Close)
                return object;
            var message = new $root.xtp.Close();
            if (object.error != null) {
                if (typeof object.error !== "object")
                    throw TypeError(".xtp.Close.error: object expected");
                message.error = $root.xtp.Error.fromObject(object.error);
            }
            return message;
        };

        /**
         * Creates a plain object from a Close message. Also converts values to other types if specified.
         * @function toObject
         * @memberof xtp.Close
         * @static
         * @param {xtp.Close} message Close
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        Close.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults)
                object.error = null;
            if (message.error != null && message.hasOwnProperty("error"))
                object.error = $root.xtp.Error.toObject(message.error, options);
            return object;
        };

        /**
         * Converts this Close to JSON.
         * @function toJSON
         * @memberof xtp.Close
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        Close.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return Close;
    })();

    xtp.End = (function() {

        /**
         * Properties of an End.
         * @memberof xtp
         * @interface IEnd
         * @property {xtp.IError|null} [error] End error
         */

        /**
         * Constructs a new End.
         * @memberof xtp
         * @classdesc Represents an End.
         * @implements IEnd
         * @constructor
         * @param {xtp.IEnd=} [properties] Properties to set
         */
        function End(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * End error.
         * @member {xtp.IError|null|undefined} error
         * @memberof xtp.End
         * @instance
         */
        End.prototype.error = null;

        /**
         * Creates a new End instance using the specified properties.
         * @function create
         * @memberof xtp.End
         * @static
         * @param {xtp.IEnd=} [properties] Properties to set
         * @returns {xtp.End} End instance
         */
        End.create = function create(properties) {
            return new End(properties);
        };

        /**
         * Encodes the specified End message. Does not implicitly {@link xtp.End.verify|verify} messages.
         * @function encode
         * @memberof xtp.End
         * @static
         * @param {xtp.IEnd} message End message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        End.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            if (message.error != null && Object.hasOwnProperty.call(message, "error"))
                $root.xtp.Error.encode(message.error, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
            return writer;
        };

        /**
         * Encodes the specified End message, length delimited. Does not implicitly {@link xtp.End.verify|verify} messages.
         * @function encodeDelimited
         * @memberof xtp.End
         * @static
         * @param {xtp.IEnd} message End message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        End.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes an End message from the specified reader or buffer.
         * @function decode
         * @memberof xtp.End
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {xtp.End} End
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        End.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.xtp.End();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1:
                    message.error = $root.xtp.Error.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            return message;
        };

        /**
         * Decodes an End message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof xtp.End
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {xtp.End} End
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        End.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies an End message.
         * @function verify
         * @memberof xtp.End
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        End.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            if (message.error != null && message.hasOwnProperty("error")) {
                var error = $root.xtp.Error.verify(message.error);
                if (error)
                    return "error." + error;
            }
            return null;
        };

        /**
         * Creates an End message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof xtp.End
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {xtp.End} End
         */
        End.fromObject = function fromObject(object) {
            if (object instanceof $root.xtp.End)
                return object;
            var message = new $root.xtp.End();
            if (object.error != null) {
                if (typeof object.error !== "object")
                    throw TypeError(".xtp.End.error: object expected");
                message.error = $root.xtp.Error.fromObject(object.error);
            }
            return message;
        };

        /**
         * Creates a plain object from an End message. Also converts values to other types if specified.
         * @function toObject
         * @memberof xtp.End
         * @static
         * @param {xtp.End} message End
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        End.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults)
                object.error = null;
            if (message.error != null && message.hasOwnProperty("error"))
                object.error = $root.xtp.Error.toObject(message.error, options);
            return object;
        };

        /**
         * Converts this End to JSON.
         * @function toJSON
         * @memberof xtp.End
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        End.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return End;
    })();

    xtp.Error = (function() {

        /**
         * Properties of an Error.
         * @memberof xtp
         * @interface IError
         * @property {string|null} [typeName] Error typeName
         * @property {string|null} [textMessage] Error textMessage
         */

        /**
         * Constructs a new Error.
         * @memberof xtp
         * @classdesc Represents an Error.
         * @implements IError
         * @constructor
         * @param {xtp.IError=} [properties] Properties to set
         */
        function Error(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * Error typeName.
         * @member {string} typeName
         * @memberof xtp.Error
         * @instance
         */
        Error.prototype.typeName = "";

        /**
         * Error textMessage.
         * @member {string} textMessage
         * @memberof xtp.Error
         * @instance
         */
        Error.prototype.textMessage = "";

        /**
         * Creates a new Error instance using the specified properties.
         * @function create
         * @memberof xtp.Error
         * @static
         * @param {xtp.IError=} [properties] Properties to set
         * @returns {xtp.Error} Error instance
         */
        Error.create = function create(properties) {
            return new Error(properties);
        };

        /**
         * Encodes the specified Error message. Does not implicitly {@link xtp.Error.verify|verify} messages.
         * @function encode
         * @memberof xtp.Error
         * @static
         * @param {xtp.IError} message Error message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Error.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            if (message.typeName != null && Object.hasOwnProperty.call(message, "typeName"))
                writer.uint32(/* id 1, wireType 2 =*/10).string(message.typeName);
            if (message.textMessage != null && Object.hasOwnProperty.call(message, "textMessage"))
                writer.uint32(/* id 2, wireType 2 =*/18).string(message.textMessage);
            return writer;
        };

        /**
         * Encodes the specified Error message, length delimited. Does not implicitly {@link xtp.Error.verify|verify} messages.
         * @function encodeDelimited
         * @memberof xtp.Error
         * @static
         * @param {xtp.IError} message Error message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Error.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes an Error message from the specified reader or buffer.
         * @function decode
         * @memberof xtp.Error
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {xtp.Error} Error
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Error.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.xtp.Error();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1:
                    message.typeName = reader.string();
                    break;
                case 2:
                    message.textMessage = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            return message;
        };

        /**
         * Decodes an Error message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof xtp.Error
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {xtp.Error} Error
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Error.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies an Error message.
         * @function verify
         * @memberof xtp.Error
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        Error.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            if (message.typeName != null && message.hasOwnProperty("typeName"))
                if (!$util.isString(message.typeName))
                    return "typeName: string expected";
            if (message.textMessage != null && message.hasOwnProperty("textMessage"))
                if (!$util.isString(message.textMessage))
                    return "textMessage: string expected";
            return null;
        };

        /**
         * Creates an Error message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof xtp.Error
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {xtp.Error} Error
         */
        Error.fromObject = function fromObject(object) {
            if (object instanceof $root.xtp.Error)
                return object;
            var message = new $root.xtp.Error();
            if (object.typeName != null)
                message.typeName = String(object.typeName);
            if (object.textMessage != null)
                message.textMessage = String(object.textMessage);
            return message;
        };

        /**
         * Creates a plain object from an Error message. Also converts values to other types if specified.
         * @function toObject
         * @memberof xtp.Error
         * @static
         * @param {xtp.Error} message Error
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        Error.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults) {
                object.typeName = "";
                object.textMessage = "";
            }
            if (message.typeName != null && message.hasOwnProperty("typeName"))
                object.typeName = message.typeName;
            if (message.textMessage != null && message.hasOwnProperty("textMessage"))
                object.textMessage = message.textMessage;
            return object;
        };

        /**
         * Converts this Error to JSON.
         * @function toJSON
         * @memberof xtp.Error
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        Error.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        return Error;
    })();

    return xtp;
})();

module.exports = $root;
